导航菜单
首页 >  The Video Embed element  > How to Add Video in HTML?

How to Add Video in HTML?

Adding videos to your web pages can enhance user engagement and deliver valuable content. Utilizing HTML elements like , , or , you can embed video files directly into your web pages, enabling seamless viewing and interaction with the video content within the webpage itself.

Table of Content

1. Adding Video Using  Tag2. Adding Video Using Iframe Tag3. Adding Video Using the object element

To embed the video in the webpage, we use the src element for mentioning the file address, and width and height attributes are used to define its size.

Ways to Insert Video in HTML

Lets see How to add/insert video in HTML with help of different examples.

1. Adding Video Using  Tag

The  tag allows us to embed videos directly into our HTML pages.

The video tag uses width, height, and control attributes to set and control the video on the web page. Also, use the source tag with the src attribute to add a source of the video. To ensure compatibility across browsers, provide multiple video formats (MP4, WebM, Ogg) within the  tag.

Example: In this example, we are using the above-discussed approach.

htmlHow to Add Video in HTML

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20240719011849/Video-Tag.mp42. Adding Video Using Iframe Tag

Embedding a video via iframe allows seamless integration from external sources like YouTube. Simply specify the video’s URL within the iframe tag, providing width, height, and optional attributes for customization and functionality.

Example: In this example we use an iframe displaying a video from a specified source. The video is embedded with a width of 400 and a height of 200, allowing full-screen view.

HTMLUsing Iframe Tag

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20240719011925/I-Frame-Tag.mp43. Adding Video Using the object element

The element embeds a video in HTML. It supports various multimedia formats. Specify the source file using the data attribute. This method allows customization through nested elements and provides fallback content for unsupported browsers.

Example: In this example we embeds a video using the element. The video’s source and type are specified in the ‘data’ and ‘type’ attributes, respectively, with defined width and height dimensions.

HTMLUsing the object element

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20240719013807/Object-element.mp4

T

The0ne53NewsImprove Next ArticleHow to add video in HTML5 ?

相关推荐: